package main

import (
	"crmeb-common/config"
	"fmt"
	"github.com/gin-gonic/gin"
	swaggerFiles "github.com/swaggo/files"
	ginSwagger "github.com/swaggo/gin-swagger"
	_ "wiaf.cn/zhouhongjie/ztl_shop/mer_go/crmeb-admin/docs"
	"wiaf.cn/zhouhongjie/ztl_shop/mer_go/crmeb-admin/router"
)

//	@title			拓物链api
//	@version		1.0
//	@description	拓物链api项目swagger api介绍
//	@termsOfService	http://swagger.io/terms/

//	@contact.name	周弘杰
//	@contact.url	2414680855@qq.com
//	@contact.email	2414680855@qq.com

//	@license.name	Apache 2.0
//	@license.url	http://www.apache.org/licenses/LICENSE-2.0.html

//	@host		localhost:3000
//	@BasePath	/

//	@securityDefinitions.basic	BasicAuth

// @externalDocs.description	OpenAPI
// @externalDocs.url			https://swagger.io/resources/open-api/
func main() {
	// 初始化数据库
	//db := initialize.MerDb
	/*db.AutoMigrate(
		&admin.SystemAdmin{},
		&admin.SystemMenu{},
		&admin.SystemPermissions{},
		&admin.SystemRole{},
		&admin.SystemRoleMenu{},
	)*/
	//
	//注册swagger路由
	r := gin.Default()

	//swagger:
	url := ginSwagger.URL("/swagger/doc.json") // The url pointing to API definition
	r.GET("/swagger/*any", ginSwagger.WrapHandler(swaggerFiles.Handler, url))

	adminRouter := router.RouterGroupApp.Admin
	PrivateGroup := r.Group("/api/platform") // 注册平台路由
	// admin 路由注册
	{

		adminRouter.InitBaseRouter(PrivateGroup)

	}

	fmt.Println("router register success")

	//run

	r.Run(fmt.Sprintf("%s:%d", config.GlobalConfig.Server.Address, config.GlobalConfig.Server.Port))

}
